const { Model } = require('../index');

class User extends Model {
    static get tableName() {
        return 'user';
    }

    static get relationMappings() {
        return {
            // Create a mapping with the user model
            //  A user has many user_stock
            user_stock: {
                relation: Model.HasManyRelation,
                modelClass: `${__dirname}/user_stock.js`,
                // Where the two are joined
                join: {
                    from: 'user.id',
                    to: 'user_stock.userId'
                }
            },
            //  A user has many user_tag
            user_tag: {
                relation: Model.HasManyRelation,
                modelClass: `${__dirname}/user_tag.js`,
                // Where the two are joined
                join: {
                    from: 'user.id',
                    to: 'user_tag.userId'
                }
            }
        };
    }
}

module.exports = User;
//a = u.tableName;